package com.atguigu.gmall.item.all.controller;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.product.client.ProductFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
public class IndexController {
    @Autowired
    private ProductFeignClient productFeignClient;

    // www.gmall.com/   www.gmall.com/index.html
    @GetMapping({"/","index.html"})
    public  String index(Model model){
        //获取数据
        List<JSONObject> baseCategoryList = productFeignClient.getBaseCategoryList();
        //后台需要存储${list}
        model.addAttribute("list",baseCategoryList);
        return "index/index";
    }
}
